<template>
	<view>
		<view class="header_bt_01">
			<image src="http://124.222.72.174:8008/images/头像/头像2.jpg" class="hander_tx"></image>
			<uni-search-bar class="uni-mt-10" style="color: #f3f3f3;" bgColor="#F8F8F8" radius="100"
				placeholder="搜索(闲置/寻物)" clearButton="auto" cancelButton="auto" @confirm="search" />
		</view>
		<view class="uni_second_t">
			<text>扑扑数据展示</text>
		</view>
		<uni-group mode="card" top=20>
			<view style="position:relative;height:660rpx;width:320rpx;padding-left: 6rpx; " v-for="(item,i) in ShopxzList" :key="i">
				<view style="position: absolute;">
					<view class="uni-second-left-s">
						<!-- 商品图片-->
						<image class="uni-second-left-ShopImg" :src="item.data1.img"></image>
						<!-- 商品名称-->
						<text class="uni-second-left-ShopName">{{ item.data1.name.length>18?item.data1.name.substr(0,19)+"...":item.data1.name }}</text>
							<!-- 小标题 -->
							<text class="uni-second-left-ShopName1">{{ item.data1.sub_title }}</text>
							<!-- 产地 -->
							<text class="uni-second-left-ShopName2">{{ item.data1.origin }}</text>
							<!-- 份量 -->
							<text class="uni-second-left-ShopName3">{{ item.data1.spec }}</text>
							<!-- 价格 -->
							<text class="uni-second-left-ShopName4">￥{{ item.data1.price }}</text>
							<image @click="offBx(item.id)" src="https://bkimges.oss-cn-beijing.aliyuncs.com/Img/关闭.png" style="position: absolute;height: 35px;width: 35px;top: -10px;left: 140px;"></image>
						<!-- 用户头像-->
						<image class="uni-second-left-UserImg" src="http://124.222.72.174:8008/images/头像/头像5.jpg"></image>
						<!-- 用户名称-->
						<text class="uni-second-left-UserName">A忙死了啊</text>
					</view>
					<view class="uni-second-right-s">
						<!-- 商品图片-->
						<image class="uni-second-right-ShopImg" :src="item.data2.img"></image>
						<!-- 商品名称-->
						<text class="uni-second-right-ShopName">{{ item.data2.name }}</text>
						<!-- 用户头像-->
						<image class="uni-second-right-UserImg" src="http://124.222.72.174:8008/images/头像/头像5.jpg"></image>
						<!-- 用户名称-->
						<text class="uni-second-right-UserName">忙不完啊</text>
						<!-- 小标题 -->
						<text class="uni-second-left-ShopName1">{{ item.data2.sub_title }}</text>
						<!-- 产地 -->
						<text class="uni-second-left-ShopName2">{{ item.data2.origin }}</text>
						<!-- 份量 -->
						<text class="uni-second-left-ShopName3">{{ item.data2.spec }}</text>
						<!-- 价格 -->
						<text class="uni-second-left-ShopName4">￥{{ item.data2.price }}</text>
						<image  @click="offBx(item.id)" src="https://bkimges.oss-cn-beijing.aliyuncs.com/Img/关闭.png" style="position: absolute;height: 35px;width: 35px;top: -10px;left: 140px;"></image>
					</view>
				</view>
			</view>
		</uni-group>
		<view style="padding:5px 0px 20px 0px;">
			<uni-load-more color="#007AFF" :status="status" iconType="auto" />
		</view>
		<view style="height: 50px;">

		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				//临时数据存储变量转换 成指定格式用
				Lslist: [],
				//商品展示数据
				ShopxzList: [],
				status: 'more',
				pageNum: 1,

			};
		},
		onLoad() {
			this.getXZList()
		},
		methods: {
			async getXZList() {
				// 3.1 发起请求
				const {
					data: res
				} = await uni.$http.get('/api/project/getPuPulist', {})
				let temp = {}
				res.data.forEach((item, index, arr) => {
					if (index % 2 == 0) {
						temp['data1'] = item
					} else if (index % 2 == 1) {
						temp['data2'] = item
						this.ShopxzList.push(temp)
						temp = {}
					}
				})
			},
			offBx(id){
				let index=this.ShopxzList.findIndex(val=>val.id===id)
				index !==-1 && this.ShopxzList.splice(index,1)
			},
			async search(val){
				console.log(val)
				var str = val.value
				// 3.1 发起请求
				const {
					data: res
				} = await uni.$http.post('/api/project/getPuPulistlike', {
					text:str
				})
				this.ShopxzList=[]
				let temp = {}
				res.data.forEach((item, index, arr) => {
					if (index % 2 == 0) {
						temp['data1'] = item
					} else if (index % 2 == 1) {
						temp['data2'] = item
						this.ShopxzList.push(temp)
						temp = {}
					}
				})
			},
			ShopToxq(no,item) {
				uni.setStorage({
					key:'xx',
					data:item,
					success:function(){
						console.log("向下级发送："+item)
					}
				})
				uni.navigateTo({
					url: '/pages/second_hand/details/details?on=' + no
				})
				
			},
			async getmo() {
				// 3.1 发起请求
				const {
					data: res
				} = await uni.$http.get('/api/project/getPuPulist', {})
					let temp = {}
					res.data.forEach((item, index, arr) => {
						if (index % 2 == 0) {
							temp['data1'] = item
						} else if (index % 2 == 1) {
							temp['data2'] = item
							this.ShopxzList.push(temp)
							temp = {}
						}
					})
					this.status = 'more'
				}
			},
			onPullDownRefresh() {
				console.log("上拉啦")
			},
			onReachBottom() {
				console.log("触底啦")
				this.status = 'loading'
				const that = this;
				setTimeout(function() {
					that.pageNum++,
						that.getmo()
				}, 1000);
			},

		
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
		font-size: 17px;
	}

	//头部样式
	.header_bt_01 {
		height: 115rpx;
		background-color: #FFFFFF;
		border-bottom: 2px solid #F7F7F7;

	}

	//头部样式--头像
	.hander_tx {
		width: 90rpx;
		height: 90rpx;
		border-radius: 100px;
		margin: 0px 0px 0px 8px;
	}

	//头部样式--取消字体 白色
	/deep/ .uni-searchbar__cancel {
		padding-left: 10px;
		line-height: 36px;
		font-size: 14px;
		color: #f3f3f3;
	}

	//二手转卖字体样式
	.uni_second_t {
		//position: absolute;
		//left: 20rpx;
		//top: 130rpx;
		width: 250rpx;
		height: 42rpx;
		display: flex;
		font-family: "仿宋 Bold", 仿宋;
		font-weight: 700;
		font-style: normal;
		font-size: 18px;
		padding-top: 10rpx;
		margin: 10px;
	}

	//左侧商品样式
	.uni-second-left-s {
		position: absolute;
		left: -12rpx;
		top: 0px;
		width: 320rpx;
		height: 630rpx;
	}

	//右侧商品样式
	.uni-second-right-s {
		position: absolute;
		left: 332rpx;
		top: 0px;
		width: 320rpx;
		height: 630rpx;
	}

	//左右侧品图片样式
	.uni-second-left-ShopImg {
		position: absolute;
		width: 320rpx;
		height: 340rpx;
		left: 0px;
		top: 0px;
		border-radius: 15px;

	}

	.uni-second-right-ShopImg {
		position: absolute;
		width: 320rpx;
		height: 340rpx;
		left: 0px;
		top: 0px;
		border-radius: 15px;
	}

	//商品名称样式
	.uni-second-left-ShopName {
		position: absolute;
		width: 300rpx;
		height: 74rpx;
		left: 10rpx;
		top: 350rpx;
		visibility: inherit;
		font-size: 12px;
	}
	.uni-second-left-ShopName1 {
		position: absolute;
		width: 300rpx;
		height: 74rpx;
		left: 10rpx;
		top: 420rpx;
		visibility: inherit;
		font-size: 12px;
		color: #999999;
	}
	.uni-second-left-ShopName2 {
		position: absolute;
		    width: 200rpx;
		    height: 40rpx;
		    left: 10rpx;
		    top: 490rpx;
		    visibility: inherit;
		    font-size: 12px;
		    color: #999999;
	}
	.uni-second-left-ShopName3 {
		position: absolute;
		    width: 150rpx;
		    height: 74rpx;
		    left: 180rpx;
		    top: 490rpx;
		    visibility: inherit;
		    font-size: 12px;
		    /* color: greenyellow; */
		    font-weight: 600;
	}
	.uni-second-left-ShopName4 {
		    position: absolute;
		    width: 100rpx;
		    height: 74rpx;
		    left: 230rpx;
		    top: 560rpx;
		    visibility: inherit;
		    font-size: 16px;
		    color: red;
		    font-weight: 600;
	}
	

	.uni-second-right-ShopName {
		position: absolute;
		width: 330rpx;
		height: 74rpx;
		left: 10rpx;
		top: 350rpx;
		visibility: inherit;
		font-size: 12px;
	}

	//头像样式
	.uni-second-left-UserImg {
		position: absolute;
		left: 10rpx;
		top: 540rpx;
		width: 60rpx;
		height: 60rpx;
		display: flex;
		border-radius: 100px;
	}

	.uni-second-right-UserImg {
		position: absolute;
		left: 10rpx;
		top: 540rpx;
		width: 60rpx;
		height: 60rpx;
		display: flex;
		border-radius: 100px;
	}

	//用户昵称
	.uni-second-left-UserName {
		position: absolute;
		left: 80rpx;
		top: 560rpx;
		width: 160rpx;
		height: 60rpx;
		display: flex;
		font-size: 12px;
	}

	.uni-second-right-UserName {
		position: absolute;
		left: 80rpx;
		top: 560rpx;
		width: 160rpx;
		height: 60rpx;
		display: flex;
		font-size: 12px;
	}

	//图片框
	.uni-second-left-Live {
		position: absolute;
		left: 240rpx;
		top: 450rpx;
		width: 80rpx;
		height: 60rpx;
		display: flex;
		font-size: 10px;
		color: #C1C0C0;
	}

	.uni-second-right-Live {
		position: absolute;
		left: 240rpx;
		top: 450rpx;
		width: 80rpx;
		height: 60rpx;
		display: flex;
		font-size: 10px;
		color: #C1C0C0;

	}

	//哎想样式
	.uni-second-left-Live1 {
		width: 40rpx;
		height: 32rpx;
		padding-right: 3px;
	}

	.uni-second-right-Live1 {
		width: 40rpx;
		height: 32rpx;
		padding-right: 3px;
	}
</style>
